package com.ship.controller;

import com.ship.commens.Result;
import com.ship.service.EcharsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/echars")
public class EcharsController {

    @Resource
    private EcharsService echarsService;

    //船与船员
    @RequestMapping("/getShipWithUserCount.do")
    public Result getShipWithUserCount(){
        return echarsService.findShipWithUserCount();
    }

    /*温度*/
    @RequestMapping("/getShipTemperatureById.do")
    public Result getShipTemperatureById(Long shipId){
        if (shipId==null || shipId<1){
            return Result.DATA_FORMAT_ERROR;
        }
        return echarsService.findTemperaturesByShipId(shipId);
    }

    /*湿度*/
    @RequestMapping("/getShipHumidityById.do")
    public Result getShipHumidityById(Long shipId){
        if (shipId==null || shipId<1){
            return Result.DATA_FORMAT_ERROR;
        }
        return echarsService.findHumiditysByShipId(shipId);
    }
}
